<?php



namespace app\superadmin\controller;


use app\common\controller\SuperadminBase;
use think\Controller;

use think\Request;

use think\Session;

use think\Db;

use app\superadmin\model\Service as Model;




class Service extends SuperadminBase

{

    public function index()

    {   
        return $this->fetch();

    }



    public function gList(Request $request) {

         //获取每页显示的条数

        $limit= $request->param('limit');

        //获取当前页数

        $page= $request->param('page');


        $name = $request->param('name');


        $adminid = session('adminid');
      
       

        $list = Model::where('name', 'like', '%' . $name . '%')->order('px')->paginate($limit,false,['page'=>$page])->toArray();    

        return json(['code'=>0,'msg'=>'','count'=>$list['total'],'data'=>$list['data']]);

    }



    // 编辑
    public function edit()
    {   

        if(\request()->isPost()){

            $data  = input('post.');
           
            Model::where('id',$data['id'])->update($data);

            return json(['code'=>1, 'message'=>'修改成功']);


        }else{

            $id  = input('id');

            $info = Model::where('id',$id)->find();

            $this->assign('info', $info);

            return $this->fetch();

        }
        
    }






    public function editpx()

    {
        $id    = $this->request->param('id');
        $px = $this->request->param('px');

        $info = Model::where('id', $id)->update(['px'=>$px]);

        return 1;

       
    }





}

